<?php
namespace Database;

class ProductAgent extends Base
{

    public function __construct()
    {
        $this->setModel(MODEL_PRODUCTAGENT);
    }

    public function getCurrentAgent($userId, $mainProduct, $orderTime)
    {
        $sql = $this->getSql();
        $sql->field('*');
        $sql->table($this->getTable());
        $sql->where('dry_user', '=', $userId);
        $sql->andWhere('dry_main_product', '=', $mainProduct);
        $sql->andWhere('dry_start_time', '<=', $orderTime);
        $sql->andWhere('dry_end_time', '>=', $orderTime);
        $sql->setPage(1);
        $sql->setPageSize(1);
        $sql->setLimit();
        return $this->fetch($sql->get());
    }

}